<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type="text/css">
    small{font-size: 14px;color: #aaa;}
    pre{padding: 5px;background-color: #eee;}
    .textcenter{text-align: center;}
    </style>
    <script src="js/ajaxUtils.js"></script>
  </head>
  <body>
  <lable>title</lable><input type="text" id="article_title"><br>
  <lable>文章类型</lable>
<select name="article_type" id="article_type">




</select>
    



    <textarea id="editor" name="editor" rows="5"  style="display:none"></textarea>
    <br>
    <button onclick="getHtml()">发表</button>&nbsp;&nbsp;
    
    <button onclick="back()">返回</button>
    <br><br>
	<script src="HandyEditor.min.js"></script>
    <script type="text/javascript">
    let param="blog.servlet?param=getAllBlogType";
    let au=new AjaxUtils;
    au.ajaxRequest(param,(xhr)=>{
    	let json=JSON.parse(xhr.responseText);
    	let list=json.data;
    	let point=document.getElementById("article_type");
    	for(let i=0;i<list.length;i++){
    		let option=document.createElement("option");
    		option.value=list[i].typecode;
    		option.innerHTML=list[i].typename;
    		point.appendChild(option);
    	}
    	
    	
    });
    
    
    
      var he = HE.getEditor('editor');
      function getHtml(){
    	  var Text=he.getHtml();
    	 var id=GetRequest();
    	 var Type=document.getElementById("article_type").value;
    	 var title=document.getElementById("article_title").value;
    	 let aut=new AjaxUtils;
    	 let url="blog.servlet";
    	 let param="param=articleput";
    	 param+="&Text="+Text;
    	 param+="&id="+id;
    	 param+="&Type="+Type;
    	 param+="&title="+title;
    	 
    	 aut.ajaxRequestPost(url,(xhr)=>{
    		
    		
    		alert(xhr.responseText);
    		 
    	},param);
    	 	
        
      }
      function back(){
    	  window.location.href="loginpage.servlet?param=views"
      }
      function GetRequest() {
    	  
    	  var url = location.search; 
    	   var theRequest = new Object();
    	   if (url.indexOf("?")!= -1) {
    	     url=url.substr(url.indexOf("id=")+3);
    	   }
    	   return url;
    	}
    
    </script>
  </body>
</html>